import Event from './api/event'
import init from './api/init'
import {$get} from './api/api';
import http from './api/http';
App({
  onLaunch() {
    init()
    let res = wx.getSystemInfoSync();
    // wx.$cache.set('key',1)
    // wx.$cache.set('member_id',1)

    //s
    wx.$api = $get;
    wx.$request = http.post
    wx.$getBase = this.getBaseShow

    //e
    wx.$http.get(wx.$get.get_show, {}).then(rea => {
      wx.$cache.set('can', rea)
      console.log('平台',res.platform)
      if (rea.edition == 1) {
        if (res.system.indexOf('iOS')!=-1) {
          this.globalData.ios = true
        }
      }
      console.log(res, '显示参数')
    })
    wx.$http.get(wx.$get.get_share, {}).then(res => {
      wx.$cache.set('fx', res)
      console.log(res, '分享图')
    })
    wx.$http.get(wx.$get.share_list, {}).then(res => {
      console.log(res, '海报')
      wx.$cache.set('hai', res)
    })
  },
  getBaseShow(){
    return new Promise((resolve, reject) => {
      wx.$http.get(wx.$get.get_show, {}).then(rea => {
        wx.$cache.set('can', rea)
        console.log('ssss')
        resolve(rea)
      })
    })

  },
  onShow(e) {
    if (e.query.pid) {
      wx.$cache.set('pid', e.query.pid)
    }
    e.query.question_id && wx.setStorageSync('question_id',e.query.question_id)
//     let params = {
//       qroscene:"1",
//       page:'pages/homePage/homePage'
//      //page: "pages/index/index",
//  }
//  wx.$http.get(wx.$get.qrcode,params).then(res=>{
//    console.log(res,'小程序码')
//  })
  },
  globalEvent: new Event(),
  globalData: {
    thisPage: true,
    userInfo: null,
    domian: 'https://qyxm-1304170060.cos.ap-beijing.myqcloud.com/img/'
    // upload_img:'https://qyxm-1304170060.cos.ap-beijing.myqcloud.com/tx_autoload/upload_file', // 上传图片
  }
})
